package com.baiduspring.dict;

import java.util.Arrays;
import java.util.Optional;

public enum ElasticSearchIndexEnum {
    SPECIAL_COLUMN(1, "专栏"),
    SPECIAL_COLUMN_TYPE(-1, "专栏索引类型"),


    INTERLOCUTION(2, "问答");

    private Integer index;
    private String name;

    ElasticSearchIndexEnum(Integer index, String name) {
        this.index = index;
        this.name = name;
    }

    public Optional<ElasticSearchIndexEnum> getByIndex(Integer index) {
        for (ElasticSearchIndexEnum indexEnum : Arrays.asList(ElasticSearchIndexEnum.values())) {
            if (indexEnum.getIndex().equals(index)) {
                return Optional.ofNullable(indexEnum);
            }
        }
        return Optional.empty();
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
